package com.gitee.wsl.mathematics.geometry.d2

import com.gitee.wsl.mathematics.geometry.d2.contour.segment.Segment2D
import com.gitee.wsl.mathematics.vector.vec2.Vec2f
import kotlin.test.*

class SegmentTest {

    @Test
    fun shouldCalculateSimplePointAtLength() {
        val curve =
            Segment2D(Vec2f(110.0, 150.0), listOf(Vec2f(25.0, 190.0), Vec2f(210.0, 250.0)), Vec2f(210.0, 30.0))
        assertEquals(Vec2f(105.53567504882812, 152.2501678466797), curve.pointAtLength(5.0f, 0.0001), 0.0005)
        assertEquals(Vec2f(162.22564697265625, 170.3757781982422), curve.pointAtLength(120.0f, 0.0001), 0.0005)
        assertEquals(curve.start, curve.pointAtLength(-500.0f, 0.0001))
        assertEquals(curve.end, curve.pointAtLength(500.0f, 0.0001))
    }
}